package situ.autoweter.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import situ.autoweter.service.SyDeptService;
import situ.autoweter.entity.SyDept;
import java.util.*;
/**
 * SyDept的路由接口服务
 * 
 * @author 胡文
 *
 */
@Controller
public class SyDeptController {

	/** SyDeptService服务 */
	@Autowired
	private SyDeptService syDeptService;
	
	/**
	 * 查询所有SyDept数据的方法
	 * @param value
	 * @return
	 */
	@RequestMapping(value = "querySyDept", produces = {"application/json;charset=UTF-8"})
	public String find(SyDept value,Map map) {
		 List<SyDept> list= syDeptService.find(value);
         map.put("items",list);
         return "页面名称自己改";
	}
	
	/**
	 * 通过id查询SyDept数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "querySyDeptById/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") Integer id,Map map) {
        SyDept obj=  syDeptService.findOne(id);
        map.put("SyDept",obj);
        return "页面名称自己改";
	}
	
	/**
	 * 插入SyDept属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "saveSyDept", produces = {"application/json;charset=UTF-8"})
	public String save(SyDept value) {
		  syDeptService.saveNotNull(value);
        return "redirect:/querySyDept";
	}
	
	/**
	 * 更新SyDept属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "updateSyDept", produces = {"application/json;charset=UTF-8"})
	public String update(SyDept value) {
		  syDeptService.updateNotNullById(value);
          return "redirect:/querySyDept";
	}
	
	/**
	 * 通过id删除SyDept数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "delSyDeptById/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") Integer id) {
		  syDeptService.deleteById(id);
          return "redirect:/querySyDept";
	}
}
